<?php

namespace hiduoke\services\formBuilder\traits;

use hiduoke\services\formBuilder\element\ElAlert;
use hiduoke\services\formBuilder\element\ElCollapse;
use hiduoke\services\formBuilder\element\ElCollapseItem;
use hiduoke\services\formBuilder\element\ElTabPane;
use hiduoke\services\formBuilder\element\ElTabs;

trait DkElement
{
    public static function ElAlert()
    {
        $alert = new ElAlert();
        return $alert;
    }

    /**
     * 选项卡组
     * @param string $value 绑定值，选中选项卡的 name
     * @param string $type 风格类型 card/border-card
     * @return ElTabs
     */
    public static function ElTabs($value = '', $type = '')
    {
        $res = new ElTabs();
        return $res->value($value)->type($type);
    }

    /**
     * 选项卡标签
     * @param string $label 选项卡标题
     * @param string $name 与选项卡绑定值 value 对应的标识符，表示选项卡别名
     * @return ElTabPane
     */
    public static function ElTabPane($label = '', $name = '')
    {
        $res = new ElTabPane();
        return $res->label($label)->name($name);
    }

    /**
     * 折叠面板组
     * @param string|array $value 当前激活的面板(如果是手风琴模式，绑定值类型需要为string，否则为array)
     * @return ElCollapse
     */
    public static function ElCollapse($value = '', $accordion = false)
    {
        $res = new ElCollapse();
        return $res->value($value)->accordion($accordion);
    }

    /**
     * 折叠面板选项
     * @param string $title 标题
     * @param string $name 对应ElCollapse value
     * @return ElCollapseItem
     */
    public static function ElCollapseItem($title = '', $name = '')
    {
        return (new ElCollapseItem())->title($title)->name($name);
    }
}
